home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MEMORY.SWG / 0041_Testing Memory.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  1KB  |  45 lines

  1. {
  2. > I have a rather irritating problem with TP:
  3. >
  4. > When I set my memory requirements ($M compile-time directive) to
  5. > 16384, 0, 655360 [stack, heapmin and heapmax, respectively] I can't
  6. > shell to DOS as there's no heap free for it [and you can't change the
  7. > mem requirements on the fly] to do so, however, when my information
  8. > screen displays itself, it correctly shows MemAvail. [a longint
  9. > containing the amount of RAM free]  As I decrease heapmax, the MemAvail
  10. > output also decreases, which is not good, especially since shelling and
  11. > running MEM /C directly contradicts it.  If somebody can make sense of
  12. > this mess, can you fix my problem?  Thanks a bunch...
  13.  
  14. Have you checked out the Memory Unit that comes with TP 7 (maybe 6). It has
  15. several procs that may help you out, notable  SetMemTop() which allows you
  16. to decrease your heap on the fly. I haven't actually played with this
  17. commands yet, but it may be worth your while to check'em out.}
  18.  
  19. {$A-,B-,D+,E-,F-,G+,I+,L+,N-,O-,P-,Q-,R+,S+,T-,V+,X+,Y+}
  20. {$M 16384,0,655360}
  21.  
  22. {$Tested with TP 7}
  23.  
  24. Program TestMem;
  25.  
  26. Uses Memory,Dos;
  27.  
  28. Type PStruct = ^TStruct;
  29.      TStruct = Record
  30.        Name: String;
  31.        Age : Byte;
  32.      end;
  33.  
  34. Var
  35.    PS: PStruct;
  36. begin
  37.   New(PS);
  38.   SetMemTop(HeapPtr);   {Without this, the shell fails}
  39.   SwapVectors;
  40.   Exec(GetEnv('Comspec'),'');
  41.   SwapVectors;
  42.   SetMemTop(HeapEnd);   {Restore your heap}
  43.   Dispose(PS);
  44. end.
  45.